﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GestionEco;
using GestionCases;

namespace Ecosystème
{
    public partial class frmPlateau : Form
    {
        public delegate void ArgDelegate(DelArgPlateauSim infosSim);
        private List<EtreVivant> evCourant;


        public frmPlateau()
        {
            InitializeComponent();
            evCourant = new List<EtreVivant>();
            this.pnlPlateau.Paint += new System.Windows.Forms.PaintEventHandler(afficherLesEtresVivants);
            Jeu.evArg += new ArgDelegate(this.affichageDesInfos);
            Jeu.simulation();
            
           
        }

        private void btnRetour_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void affichageDesInfos(DelArgPlateauSim argLesInfos){

            this.textBoxInfos.Text += argLesInfos.infos;

            this.evCourant = argLesInfos.EvInfos;

            pnlPlateau.Invalidate();
            this.Refresh();
        }

        private void afficherLesEtresVivants(object sender, PaintEventArgs e)
        {
            Pen monpen = new Pen(Color.Black);

            this.evCourant.ForEach(delegate(EtreVivant unEv)
            {
                monpen.Color = unEv.getCouleur(); ;
                e.Graphics.DrawRectangle(monpen, unEv.position.getX(), unEv.position.getY(), 1, 1);
            });

            this.Refresh();


        }
    }
}
